package com.heima.admin.controller;

import com.alibaba.fastjson.JSON;
import com.heima.admin.annotation.OperationFill;
import com.heima.api.admin.IUserClient;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class UserIdentificationController {
    @Autowired
    private IUserClient userIdentifyClient;

    @OperationFill
    @PostMapping("/api/v1/auth/list")
    public PageResponseResult list(@RequestBody AuthDto dto){
        log.info("用户实名认证查询");
        return userIdentifyClient.list(dto);
    }

    @OperationFill
    @PostMapping("/api/v1/auth/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto){
        log.info("用户实名认证失败:{}",dto);
        return userIdentifyClient.authFail(JSON.toJSONString(dto));
    }

    @OperationFill
    @PostMapping("/api/v1/auth/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto){
        log.info("用户实名认证通过");
        return userIdentifyClient.authPass(dto);
    }
}
